﻿using System;

namespace Smile.Network
{
    public class UploadInfo
    {
        // @Properties
        /// <summary>Gets the size of the item to upload.</summary>
        ///
        /// <value>The item upload size.</value>
        public int Size
        {
            get
            {
                return _size;
            }
        }

        /// <summary>Gets or sets the number of bytes currently uploaded.</summary>
        ///
        /// <value>The number of bytes currently uploaded.</value>
        public int Uploaded
        {
            get
            {
                return _uploaded;
            }
            internal set
            {
                _uploaded = value;
            }
        }

        /// <summary>Gets the remaining numer of bytes to upload.</summary>
        ///
        /// <value>The remaining number of bytes to upload.</value>
        public int RemainingUpload
        {
            get
            {
                return Size - Uploaded;
            }
        }

        /// <summary>Gets or sets the current progress of the upload.</summary>
        ///
        /// <value>The current progress of the download (between 0 and 100).</value>
        public int Progress
        {
            get
            {
                return _progress;
            }
            internal set
            {
                if (value <= 100)
                {
                    _progress = value;
                }
                else
                {
                    _progress = 100;
                }
            }
        }


        // @Public
        /// <summary>Default constructor.</summary>
        public UploadInfo()
        {
        }

        /// <summary>Constructor.</summary>
        ///
        /// <param name="data">The data to upload.</param>
        public UploadInfo(byte[] data)
        {
            _size = data.Length;
        }

        /// <summary>Constructor.</summary>
        ///
        /// <param name="data">The string to upload.</param>
        public UploadInfo(string data)
        {
            _size = data.Length;
        }


        // @Private
        int _size = 0;
        int _uploaded = 0;
        int _progress = 0;
    }
}
